package mysgoog.board;

import java.util.*;

public class PosSet extends HashSet<Integer>
{
    private static final long serialVersionUID = 1L;

    public PosSet()
    {
        super();
    }
    public int containCount(Collection<Integer> other)
    {
        int res = 0;
        for (Integer pos : other)
            if (this.contains(pos))
                res++;
        return res;
    }
    public PosSet intersection(PosSet other)
    {
        PosSet res = new PosSet();
        for (Integer t : other)
        {
            if (this.contains(t))
                res.add(t);
        }
        return res;
    }
    public PosSet union(PosSet other)
    {
        PosSet res = new PosSet();
        res.addAll(this);
        res.addAll(other);
        return res;
    }
    public PosSet diff(PosSet other)
    {
        PosSet res = new PosSet();
        for (Integer i : other)
            if (!this.contains(i))
                res.add(i);
        for (Integer i : this)
            if (!other.contains(i))
                res.add(i);
        return res;
    }
    public Integer getOne()
    {
        for (Integer pos : this)
            return pos;
        throw new Error("!!!");
    }
}
